/* Copyright (C) 2011. ChengDu Unicon system, All Rights Reserved */

/*""FILE COMMENT""******************************* Technical reference data ****
* File Name	: cam.h
* Version 	: 1.00
* Device 	: SH72543
* Tool Chain 	: 
* H/W Platform	: 
* Description 	: 
******************************************************************************/

/******************************************************************************
* History 	: 11.08.2011 Ver. 1.00 First Release
*		: 
*FILE COMMENT END*********************************************************/

/* Define cam speed data ring buffer size */
#define CAM_SPEED_BUF_SIZE 20

/* Define cam angle data ring buffer size */
#define CAM_ANGLE_BUF_SIZE 20

/* Define CAM Hardware Register Config Struct */
typedef struct
{
  CPU_INT08U edgeType    :2;   //CAM edge capture, 00 disable, 01 rising, 10 falling, 11 both edge
  CPU_INT08U hardWareCfg :2;   //CAM input hardware config
  CPU_INT08U             :4;
  CPU_INT08U minPW;         //CAM input min pulse width, The unit is uS
  CPU_INT16U magTrigMin;    //CAM input mag min trigger level
  CPU_INT16U magTrigOutMax; //CAM input mag max trigger output
  CPU_INT16U pwmCycle; //Hz
  CPU_INT16U pwmDuty;  //0~10000(0.00%~100.00%)
  CPU_INT32U measureCycle;  //CAM measure cycle, eg. 720
}ST_CAM_HW_SET;

/* Define cam ring buffer struct */
typedef struct
{
  struct
  {
    OS_EVENT   *dataRdySem; //Cam Speed Data Semaphore
    CPU_INT08U bufCnt;  //Ring buffer count
    CPU_INT32U *inPtr;  //Ring buffer in pointer
    CPU_INT32U *outPtr; //Ring buffer out pointer
    CPU_INT32U data[CAM_SPEED_BUF_SIZE]; //Cam time of one tooth, Unit is us
  }speed;
  
  struct
  {
    OS_EVENT   *dataRdySem; //Cam angle Data Semaphore
    CPU_INT08U bufCnt;  //Ring buffer count
    CPU_INT32U *inPtr;  //Ring buffer in pointer
    CPU_INT32U *outPtr; //Ring buffer out pointer
    CPU_INT32U data[CAM_ANGLE_BUF_SIZE]; //Cam angles, Unit is min
  }angle;
}ST_CAM;